package com.bwie.controller;

import com.bwie.pojo.TbBrand;
import com.bwie.service.TbBrandService;
import com.bwie.utils.R;
import com.bwie.vo.PageInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 军哥
 * @version 1.0
 * @description: TODO
 * @date 2025/6/20 15:30
 */

@RestController
@RequestMapping("/shop/index")
public class IndexController {

    @Autowired
    TbBrandService tbBrandService;

    /**
     * @description 分页获取品牌列表
     * @params [pageInfoVo]
     * @return com.bwie.utils.R
     * @author 军哥
     * @date 2025/6/20 15:32
     */
    @PostMapping("/getBrandList")
    public R getBrandList(@RequestBody PageInfoVo pageInfoVo) {
        return tbBrandService.getBrandList(pageInfoVo);
    }

    /**
     * @description 添加品牌
     * @params []
     * @return com.bwie.utils.R
     * @author 军哥
     * @date 2025/6/20 15:32
     */
    @PostMapping("/addBrand")
    public R addBrand(@RequestBody @Validated TbBrand tbBrand) {
        return tbBrandService.addBrand(tbBrand);
    }

    /**
     * @description 修改品牌显示状态
     * @params [tbBrand]
     * @return com.bwie.utils.R
     * @author 军哥
     * @date 2025/6/20 16:52
     */
    @PostMapping("/changeBrandStatus")
    public R changeBrandStatus(@RequestBody TbBrand tbBrand) {
        return tbBrandService.changeBrandStatus(tbBrand);
    }

    /**
     * @description 删除品牌
     * @params [brandId]
     * @return com.bwie.utils.R
     * @author 军哥
     * @date 2025/6/21 10:23
     */
    @PostMapping("/deleteBrand/{brandId}")
    public R deleteBrand(@PathVariable("brandId") Integer brandId) {
        return tbBrandService.deleteBrand(brandId);
    }

    /**
     * @description 批量删除品牌
     * @params [brandList]
     * @return com.bwie.utils.R
     * @author 军哥
     * @date 2025/6/21 10:50
     */
    @PostMapping("/deleteBatchBrand")
    public R deleteBatchBrand(@RequestBody List<TbBrand> brandList) {
        return tbBrandService.deleteBatchBrand(brandList);
    }

}
